package com.milo.string;

import com.alibaba.fastjson.JSONObject;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: Milogenius
 * @create: 2019-06-04 10:49
 * @description:
 **/
public class StringTest {

    public static void main(String[] args) throws UnsupportedEncodingException {

        String s = "{\"body\":{\"msg\":\"支付成功\",\"ordno\":\"93120190426155659918992\",\"payType\":\"3\",\"status\":\"1\"},\"header\":{\"apiid\":\"70002\",\"busdt\":\"20190604\",\"chnno\":\"10001\",\"ipaddr\":\"172.28.8.181\",\"reqjnl\":\"6350203247825108585\",\"reqopetm\":\"20190604100708\",\"respcode\":\"\",\"respjnl\":\"\",\"respmsg\":\"\",\"respopetm\":\"\",\"version\":\"1.0\"},\"security\":{\"desvalue\":\"iYUjH/JRw9DpLWun8YBqco4JstQiiMLhxAjyGHhxJso=\",\"signvalue\":\"40032212b5ffce19fc32efe24cda4439\"}}";
        JSONObject resultJson = JSONObject.parseObject(s.replaceAll("\\\\", ""));
        JSONObject resHeader = resultJson.getJSONObject("header");
        JSONObject resBody = resultJson.getJSONObject("body");
        JSONObject resSecurity = resultJson.getJSONObject("security");

        String reqopetm = resHeader.getString("reqopetm");
        String rdesvalue = resSecurity.getString("desvalue");
        String signvalue = resSecurity.getString("signvalue");


        Map<String, JSONObject> mapsign = new HashMap<String, JSONObject>();
        mapsign.put("body", resBody);
        mapsign.put("header", resHeader);
        //
        JSONObject jsonSign = JSONObject.parseObject(JSONObject.toJSONString(mapsign));
        System.out.println(jsonSign.toJSONString());
          /*  CryptUtilImpl cryptUtil = new CryptUtilImpl();
            String signKey = ScanCodePayConstants.SIGN_KEY;
            String desKey = ScanCodePayConstants.DES_KEY;
            String operationTime = reqopetm;
            desKey = desKey + operationTime;
            String desvalue = cryptUtil.cryptDes(desKey, desKey);
            signKey = signKey + operationTime;

            String signatureValue = cryptUtil.cryptMd5(jsonSign.toString(), signKey);*/
    }
}
